package com.ebb.classes;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class EBBBmpLoader {
	public static Bitmap LoadImage(String $imagePath) {
		InputStream inputStream = OpenHttpConnection($imagePath);
		Bitmap bm = BitmapFactory.decodeStream(inputStream);

		return bm;
	}

	private static InputStream OpenHttpConnection(String $imagePath) {
		InputStream stream = null;
		try {
			URL url = new URL($imagePath);
			HttpURLConnection urlConnection = (HttpURLConnection) url
					.openConnection();
			urlConnection.setRequestMethod("GET");
			urlConnection.connect();
			if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
				stream = urlConnection.getInputStream();
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return stream;
	}
}
